package com.sina.shop.util;

import java.util.Date;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description: 生成订单号
 * 段浩杰   2018-01-12-15:26
 */
public class GenOrderNoUtils {

    public static String getOrderNo() {

        String orderNo = DateUtils.LocalDateFormatter("yyyyMMdd");
        String randomNum = String.valueOf(System.currentTimeMillis());
        randomNum = randomNum.substring(4, randomNum.length());

        Date date = new Date();
        Random random = new Random(date.getTime());
        int randomT = random.nextInt(999);
        while (randomT < 100) {
            randomT = random.nextInt(999);
        }

        return orderNo + randomNum + randomT;
    }

    public static void main(String[] args) {
        System.out.println(getOrderNo());
    }
}
